<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<script src="//cdn.bootcss.com/jquery/1.12.4/jquery.js"></script>
<script src="//cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
123.a.com系统<br/>
你登陆的用户名：<input id="name"/><br/>
<button id="logout">退出</button>
</body>
<script>
    $(function(){
        getInfo();
        function getInfo(){
            debugger
            var token =  getQueryVariable('token');
            if(!token){
                token = $.cookie('token');
            }
            $.get("http://localhost:8080/info?token="+token,function(data,status){
                if (data == "") {
                    window.location.href = "http://auth.sso.com:8000/index?callback=http://123.a.com:8101/indexa?token="+token;
                } else {
                    $.cookie('token',token, {domain:'a.com'});
                    $("#name").val(data);
                }
            });
        };

        $("button").click(function(){
            var token = $.cookie('token');
            $.get("http://localhost:8080/logout?token="+token,function(data,status){
                alert("退出！")
                $("#name").val("");
            });
        });

        function getQueryVariable(variable) {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                if(pair[0] == variable){return pair[1];}
            }
            return(false);
        }
    });
</script>
</html>